import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import LibraryJs from './utils'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.use(ElementUI)

Vue.config.productionTip = false

const msg = {
  data: store, // 从主应用仓库读出的数据
  utils: LibraryJs, // 从主应用读出的工具类库
  prototype: [
    { name: 'isQiankun', value: true } // 是否qiankun启用
  ]
}

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

import { registerMicroApps, start } from 'qiankun'

const ISPROD = process.env.NODE_ENV === 'production'

const apps = [
  {
    name: 'vueApp',
    entry: ISPROD ? '//47.106.100.223:5001' : '//localhost:30000', // 默认会加载这个html，解析里面的js，动态执行（子应用必须支持跨域）
    container: '#vue',
    activeRule: '/vue',
    props: msg
  },
  {
    name: 'reactApp',
    entry: ISPROD ? '//47.106.100.223:5002' : '//localhost:20000', // 默认会加载这个html，解析里面的js，动态执行（子应用必须支持跨域）
    container: '#react',
    activeRule: '/react',
    props: msg
  }
]

registerMicroApps(apps, {
  beforeLoad: [
    app => {
      console.log('[LifeCycle] before load %c%s', 'color: green;', app.name);
    }
  ],
  beforeMount: [
    app => {
      console.log('[LifeCycle] before mount %c%s', 'color: green;', app.name);
    }
  ],
  afterUnmount: [
    app => {
      console.log('[LifeCycle] after unmount %c%s', 'color: green;', app.name);
    }
  ]
}) // 注册应用
start() // 开启


